#include<iostream>
using namespace std;

int fun(int n)
{
	if (n == 0)
	{
		return 0;
	}
	int a = fun(n - 1) + n;

	return a;
}

int main()
{
	int n = 0;
	cin >> n;
	int a[2];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int arr[2] = { 0 };
	int temp[2] = { 0 };
	int total = 0;
	for (int j = 0; j < n; j++)
	{
		int i = 1;
		for (int k = 0; k < n - j - 1; k++)
		{
			if (a[k] > a[k + 1])
			{
				temp[k]++;
				temp[k + 1]++;
				arr[k] += temp[k];
				arr[k + 1] += temp[k + 1];
				swap(arr[k], arr[k + 1]);
				swap(a[k], a[k + 1]);
				swap(temp[k], temp[k + 1]);
			}
		}
	}
	for (int i = 0; i < 2; i++)
	{
		total += arr[i];
	}
	//total = fun(arr[0]) + fun(arr[1]) + fun(arr[2]);
	cout << total;


	return 0;
}